package com.jsyh.maidu.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.jsyh.maidu.R;
import com.jsyh.maidu.activity.me.ShopGoodsListActivity;
import com.jsyh.maidu.adapter.goods.GridAdapter;
import com.jsyh.maidu.adapter.home.MyGridView;
import com.jsyh.maidu.model.StoreClassModel;
import com.jsyh.shopping.uilibrary.adapter.listview.BaseAdapterHelper;
import com.jsyh.shopping.uilibrary.adapter.listview.QuickAdapter;

/**
 * Created by admin on 2017/7/17.
 */

public class StoreClassAdapter extends QuickAdapter<StoreClassModel.ClassFrist> {
    QuickAdapter<StoreClassModel.ClassSecond> adapter;
    String suppid;

    public StoreClassAdapter(Context context, int layoutResId) {
        super(context, layoutResId);
    }

    public StoreClassAdapter(Context context,String _suppid, int layoutResId) {
        super(context, layoutResId);
        this.suppid = _suppid;
    }

    @Override
    protected void convert(BaseAdapterHelper helper,final StoreClassModel.ClassFrist item) {
        helper.setText(R.id.tv_isc_class1name,item.getCat_name());
        helper.setOnClickListener(R.id.tv_isc_lookall,new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                Intent itEdit = new Intent(context,ShopGoodsListActivity.class);
                itEdit.putExtra("suppid",suppid);
                itEdit.putExtra("cat_id",item.getCat_id());
                context.startActivity(itEdit);
            }
        });
        MyGridView gv_class2=helper.getView(R.id.gv_isc_class2);
        adapter=new QuickAdapter<StoreClassModel.ClassSecond>(context,R.layout.item_store_class2,item.getChildren()) {
            @Override
            protected void convert(BaseAdapterHelper helper,final StoreClassModel.ClassSecond item) {
                helper.setText(R.id.tv_isc2_name,item.getCat_name());
                helper.setOnClickListener(R.id.tv_isc2_name,new View.OnClickListener(){
                    @Override
                    public void onClick(View view) {
                        Intent itEdit = new Intent(context,ShopGoodsListActivity.class);
                        itEdit.putExtra("suppid",suppid);
                        itEdit.putExtra("cat_id",item.getCat_id());
                        context.startActivity(itEdit);
                    }
                });
            }
        };
        gv_class2.setAdapter(adapter);

    }




}
